package alibaba_clz;

import java.util.Scanner;

/*
 * @Author: qianmingtian
 * @Date: 2020-05-27 16:18:18
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-07-08 09:29:31
 * @FilePath: \qianmingtian.github.io\code\alibaba_clz\weiqi.java
 */


public class weiqi {
    int blockLength;
    int[] block;
    static int[][] map;
    static int size;

    public void kill(int size) {
           for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                if (map[i][j] == 0)
                    continue;
                else {
                    block = new int[size * size];
                    blockLength = 1;
                    block[0] = i * 100 + j;

                    recursion(i, j);

                    if (hasQi())
                        continue;
                    else {
                        System.out.println(i + " " + j);
                        int t;
                        for (t = 0; t < blockLength; t++) {
                            // map[block[t] / 100][block[t] % 100] = 0;
                            int row = block[t] / 100;
                            int col = block[t] % 100;
                            System.out.print("(" + row + "," + col + ")  ");
                        }
                        System.out.println();
                    }
                }
            }
        }
    }

    public void recursion(int i, int j) {
        // Left
        if (i - 1 >= 0 && map[i - 1][j] == map[i][j] && isInBlock((i - 1) * 100 + j)) {
            block[blockLength] = (i - 1) * 100 + j;
            blockLength++;
            recursion(i - 1, j);
        }
        // Up
        if (j - 1 >= 0 && map[i][j - 1] == map[i][j] && isInBlock(i * 100 + j - 1)) {
            block[blockLength] = i * 100 + j - 1;
            blockLength++;
            recursion(i, j - 1);
        }
        // Right
        if (i + 1 < size && map[i + 1][j] == map[i][j] && isInBlock((i + 1) * 100 + j)) {
            block[blockLength] = (i + 1) * 100 + j;
            blockLength++;
            recursion(i + 1, j);
        }
        // Down
        if (j + 1 < size && map[i][j + 1] == map[i][j] && isInBlock(i * 100 + j + 1)) {
            block[blockLength] = i * 100 + j + 1;
            blockLength++;
            recursion(i, j + 1);
        }
    }

    public boolean hasQi() {
        int i, j;
        for (int t = 0; t < blockLength; t++) {
            i = block[t] / 100;
            j = block[t] % 100;
            if (i - 1 >= 0 && map[i - 1][j] == 0)
                return true;
            if (i + 1 < size && map[i + 1][j] == 0)
                return true;
            if (j - 1 >= 0 && map[i][j - 1] == 0)
                return true;
            if (j + 1 < size && map[i][j + 1] == 0)
                return true;
        }
        return false;
    }

    public boolean isInBlock(int neighbor) {
        for (int i = 0; i < blockLength; i++) {
            if (block[i] == neighbor)
                return false;
        }
        return true;
    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int size = in.nextInt();
        map = new int[size][size];

        for (int i = 0; i < size; i++) {
            String[] symbol = in.next().split("");
            
            for (int j = 0; j < size; j++) {
                if (symbol[j].equals(".")) {
                    map[i][j] = 0;
                } else if (symbol[j].equals("x")) {
                    map[i][j] = -1;
                } else if (symbol[j].equals("o")) {
                    map[i][j] = 1;
                }
            }
        }
        weiqi wq = new weiqi();
        wq.kill(size);
        // in.close();
        // for (int i = 0; i < size; i++) {
        //     for (int j = 0; j < size; j++) {

        //         System.out.print(map[i][j]);
        //     }
        //     System.out.println();
        // }

    }
}/*
  * @Author: qianmingtian
  * 
  * @Date: 2020-05-27 16:18:18
  * 
  * @LastEditors: qianmingtian
  * 
  * @LastEditTime: 2020-05-27 16:18:18
  * 
  * @FilePath: \qianmingtian.github.io\code\alibaba_clz\weiqi.java
  */
